| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Texture.h
1 // Texture.h
3 //
5
6 namespace nkGraphics
7 {
11 enum class TEX_TYPE
12 {
13 TEX_2D = 0,
14 TEX_3D,
15 TEX_CUBEMAP
16 } ;
17
21 enum class TEX_RENDER_FLAG
22 {
23 NO_RENDER = 0,
24 RENDER_TARGET,
25 DEPTH_RENDER_TARGET
26 } ;
27 }
28
29 namespace nkGraphics
30 {
34 class Texture : public ShaderResource, public nkExport::Exportable
35 {
36 public :
37
41 virtual ~Texture () ;
42
46 TextureCpuDataDescriptor* getCpuData () const ;
50 unsigned int getCpuSliceCount () const ;
54 bool isFromFile () const ;
58 bool isGammaCorrected () const ;
62 bool isBackBufferTex () const ;
66 TEX_TYPE getTexType () const ;
70 TEX_RENDER_FLAG getRenderFlag () const ;
74 unsigned int getNeededMipsForSize () const ;
78 virtual int getWidth () const = 0 ;
82 virtual int getHeight () const = 0 ;
86 virtual int getDepthOrArraySize () const = 0 ;
90 virtual unsigned int getMipLevels () const = 0 ;
94 virtual FORMAT getTextureFormat () const = 0 ;
98 virtual BUFFER_CPU_ACCESS_FLAG getCpuAccessRights () const = 0 ;
102 virtual BUFFER_USAGE getTextureUsage () const = 0 ;
106 virtual BUFFER_BIND_FLAG getTextureBinding () const = 0 ;
110 virtual RESOURCE_MISC_FLAG getMiscFlag () const = 0 ;
114 virtual unsigned int getSampleCount () const = 0 ;
118 virtual unsigned int getSampleQuality () const = 0 ;
122 virtual bool getAutoMipGeneration () const = 0 ;
123
124 // Setters
148 void setCpuData (const ResourceCpuDataDescriptor& data) ;
183 void addCpuDataSlice (const nkMemory::BufferView<>& data, unsigned int byteOffset = 0u, unsigned int rowByteSize = 0u, unsigned int sliceByteSize = 0u) ;
197 void addCpuDataSliceCopy (const nkMemory::BufferView<>& data, unsigned int byteOffset = 0u, unsigned int rowByteSize = 0u, unsigned int sliceByteSize = 0u) ;
210 void addCpuDataSliceForward (nkMemory::Buffer&& data, unsigned int byteOffset = 0u, unsigned int rowByteSize = 0u, unsigned int sliceByteSize = 0u) ;
222 void addCpuDataSliceRelativeToLast (unsigned int byteOffset = 0u, unsigned int rowByteSize = 0u, unsigned int sliceByteSize = 0u) ;
228 void setBackBufferTex (bool value) ;
248 void setFromImage (const nkImages::ImageView& image) ;
259 void setFromImageCopy (const nkImages::ImageView& image) ;
270 void setFromImageForward (nkImages::Image&& image) ;
275 virtual void freeCpuData () ;
286 virtual void setGammaCorrected (bool value) ;
287 virtual void setPath (nkMemory::StringView value) override ;
291 virtual void setWidth (unsigned int width) = 0 ;
295 virtual void setHeight (unsigned int height) = 0 ;
299 virtual void setDepthOrArraySize (unsigned int depth) = 0 ;
305 virtual void setMipLevels (unsigned int value) = 0 ;
309 virtual void setTextureFormat (FORMAT format) = 0 ;
315 virtual void setCpuAccessRights (BUFFER_CPU_ACCESS_FLAG rights) = 0 ;
319 virtual void setTextureUsage (BUFFER_USAGE usage) = 0 ;
323 virtual void setTextureBinding (BUFFER_BIND_FLAG binding) = 0 ;
327 virtual void setAutoMipGeneration (bool value) = 0 ;
333 virtual void copyParams (const Texture& other) = 0 ;
337 void setTextureFormatFromString (nkMemory::StringView str) ;
338
348 void setMightManuallyGenerateMip (bool value) ;
352 virtual void prepareAsTexture2d () ;
356 virtual void prepareAsCubemap () ;
360 virtual void prepareAsTexture3d () ;
366 virtual void setRenderFlag (TEX_RENDER_FLAG value) ;
374 virtual void generateMipChain (unsigned int fromMip = 0) = 0 ;
375
386 nkImages::Image convertToImage (int mip, int sliceOrArrayIndex) ;
394 virtual MapResult map (const MapRequestDescriptor& requestDesc) = 0 ;
402 virtual void unmap (const UnmapRequestDescriptor& requestDesc) = 0 ;
411 virtual void gpuCopyFrom (Texture& other, const ResourceGpuCopyDescriptor& descriptor) = 0 ;
412
413 // Import / Export
414 virtual void exportClassToTree (nkExport::Node* rootNode) override ;
415 virtual void importClassFromTree (nkExport::Node* rootNode) override ;
416
417 public :
418
419 // Statics
427 static nkMemory::UniquePtr<Texture> create (System* system = nullptr) ;
428 } ;
429 }
nkGraphics::MapResult
Contains all information of the result of a map operation on a resource.
Definition: MapResult.h:12
nkGraphics::Texture::getAutoMipGeneration
virtual bool getAutoMipGeneration() const =0
nkGraphics::RESOURCE_MISC_FLAG
RESOURCE_MISC_FLAG
Available misc flags for resources.
Definition: ResourceMiscFlag.h:12
nkGraphics::Texture::getSampleCount
virtual unsigned int getSampleCount() const =0
nkGraphics::MapRequestDescriptor
A description of a request to map a resource.
Definition: MapRequestDescriptor.h:29
nkGraphics::Texture::setFromImageCopy
void setFromImageCopy(const nkImages::ImageView &image)
nkGraphics::Texture::isGammaCorrected
bool isGammaCorrected() const
nkGraphics::Texture::prepareAsCubemap
virtual void prepareAsCubemap()
nkGraphics::Texture::getTextureUsage
virtual BUFFER_USAGE getTextureUsage() const =0
nkGraphics::TEX_TYPE::TEX_CUBEMAP
@ TEX_CUBEMAP
A cubemap.
nkGraphics::Texture::getMipLevels
virtual unsigned int getMipLevels() const =0
nkGraphics::System
Main interface with the component system.
Definition: System.h:14
nkGraphics::BUFFER_CPU_ACCESS_FLAG
BUFFER_CPU_ACCESS_FLAG
Available cpu access flags.
Definition: BufferCpuAccessFlag.h:12
nkGraphics::Texture::isFromFile
bool isFromFile() const
nkGraphics::Texture::freeCpuData
virtual void freeCpuData()
nkGraphics::Texture
A texture used for rendering, hosted on GPU.
Definition: Texture.h:35
nkGraphics::Texture::unmap
virtual void unmap(const UnmapRequestDescriptor &requestDesc)=0
nkGraphics::Texture::getMiscFlag
virtual RESOURCE_MISC_FLAG getMiscFlag() const =0
nkExport::Exportable
An interface to define objects that can be exported using this component.
Definition: Exportable.h:15
nkMemory::BufferView
A view over data.
Definition: BufferView.h:18
nkImages::ImageView
Holds all information required for an image, with no ownership over the data.
Definition: ImageView.h:14
nkGraphics::Texture::copyParams
virtual void copyParams(const Texture &other)=0
nkGraphics::UnmapRequestDescriptor
Description of an unmap request.
Definition: UnmapRequestDescriptor.h:19
nkGraphics::BUFFER_USAGE
BUFFER_USAGE
Available usage for buffers. Drives the memory used for hosting the data.
Definition: BufferUsage.h:12
nkGraphics::Texture::getCpuData
TextureCpuDataDescriptor * getCpuData() const
nkGraphics::TEX_RENDER_FLAG::DEPTH_RENDER_TARGET
@ DEPTH_RENDER_TARGET
Used as a depth target rendering.
nkGraphics::Texture::getTextureFormat
virtual FORMAT getTextureFormat() const =0
nkGraphics::Texture::generateMipChain
virtual void generateMipChain(unsigned int fromMip=0)=0
nkGraphics::Texture::setMightManuallyGenerateMip
void setMightManuallyGenerateMip(bool value)
nkGraphics::TEX_RENDER_FLAG::RENDER_TARGET
@ RENDER_TARGET
Used as a color target rendering.
nkGraphics::Texture::addCpuDataSliceRelativeToLast
void addCpuDataSliceRelativeToLast(unsigned int byteOffset=0u, unsigned int rowByteSize=0u, unsigned int sliceByteSize=0u)
nkGraphics::Texture::addCpuDataSlice
void addCpuDataSlice(const nkMemory::BufferView<> &data, unsigned int byteOffset=0u, unsigned int rowByteSize=0u, unsigned int sliceByteSize=0u)
nkGraphics::Texture::setMipLevels
virtual void setMipLevels(unsigned int value)=0
nkMemory::Buffer
A buffer holding binary data.
Definition: Buffer.h:32
nkGraphics::Texture::getTextureBinding
virtual BUFFER_BIND_FLAG getTextureBinding() const =0
nkGraphics::Texture::prepareAsTexture2d
virtual void prepareAsTexture2d()
nkGraphics::Texture::setDepthOrArraySize
virtual void setDepthOrArraySize(unsigned int depth)=0
nkExport::Node
A node in the tree structure representing the data to export / import.
Definition: Node.h:42
nkGraphics::Texture::addCpuDataSliceForward
void addCpuDataSliceForward(nkMemory::Buffer &&data, unsigned int byteOffset=0u, unsigned int rowByteSize=0u, unsigned int sliceByteSize=0u)
nkGraphics::Texture::setAutoMipGeneration
virtual void setAutoMipGeneration(bool value)=0
nkGraphics::Texture::importClassFromTree
virtual void importClassFromTree(nkExport::Node *rootNode) override
nkGraphics::Texture::setCpuAccessRights
virtual void setCpuAccessRights(BUFFER_CPU_ACCESS_FLAG rights)=0
nkGraphics::Texture::getCpuSliceCount
unsigned int getCpuSliceCount() const
nkGraphics::Texture::~Texture
virtual ~Texture()
nkGraphics::Texture::addCpuDataSliceCopy
void addCpuDataSliceCopy(const nkMemory::BufferView<> &data, unsigned int byteOffset=0u, unsigned int rowByteSize=0u, unsigned int sliceByteSize=0u)
nkGraphics::Texture::setCpuData
void setCpuData(const ResourceCpuDataDescriptor &data)
nkGraphics::Texture::setFromImage
void setFromImage(const nkImages::ImageView &image)
nkGraphics::TEX_TYPE
TEX_TYPE
The type a texture can be.
Definition: Texture.h:12
nkMemory::UniquePtr
Smart pointer owning the object instance it encapsulates.
Definition: UniquePtr.h:17
nkGraphics::Texture::setTextureUsage
virtual void setTextureUsage(BUFFER_USAGE usage)=0
nkGraphics::Texture::setHeight
virtual void setHeight(unsigned int height)=0
nkGraphics::Texture::getWidth
virtual int getWidth() const =0
nkGraphics::Texture::getTexType
TEX_TYPE getTexType() const
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkGraphics::Texture::setGammaCorrected
virtual void setGammaCorrected(bool value)
nkGraphics::Texture::setTextureFormat
virtual void setTextureFormat(FORMAT format)=0
nkGraphics::Texture::exportClassToTree
virtual void exportClassToTree(nkExport::Node *rootNode) override
nkGraphics::Texture::getSampleQuality
virtual unsigned int getSampleQuality() const =0
nkGraphics::Texture::isBackBufferTex
bool isBackBufferTex() const
nkGraphics::TEX_TYPE::TEX_2D
@ TEX_2D
A 2D texture.
nkGraphics::Texture::getCpuAccessRights
virtual BUFFER_CPU_ACCESS_FLAG getCpuAccessRights() const =0
nkGraphics::Texture::setWidth
virtual void setWidth(unsigned int width)=0
nkGraphics::Texture::setTextureFormatFromString
void setTextureFormatFromString(nkMemory::StringView str)
nkGraphics::Texture::setRenderFlag
virtual void setRenderFlag(TEX_RENDER_FLAG value)
nkGraphics::Texture::setPath
virtual void setPath(nkMemory::StringView value) override
nkGraphics::Texture::setBackBufferTex
void setBackBufferTex(bool value)
nkGraphics::TEX_RENDER_FLAG::NO_RENDER
@ NO_RENDER
Not used as a target.
nkGraphics::Texture::getDepthOrArraySize
virtual int getDepthOrArraySize() const =0
nkGraphics::Texture::getNeededMipsForSize
unsigned int getNeededMipsForSize() const
nkGraphics::FORMAT
FORMAT
Available formats for resources.
Definition: DxDefinesWrapper.h:13
nkGraphics::Texture::getRenderFlag
TEX_RENDER_FLAG getRenderFlag() const
nkGraphics::Texture::prepareAsTexture3d
virtual void prepareAsTexture3d()
nkGraphics
Encompasses all API of component NilkinsGraphics.
Definition: BoundingBox.h:7
nkGraphics::Texture::map
virtual MapResult map(const MapRequestDescriptor &requestDesc)=0
nkGraphics::Texture::setTextureBinding
virtual void setTextureBinding(BUFFER_BIND_FLAG binding)=0
nkGraphics::ResourceGpuCopyDescriptor
Holds information about a resource copy happening on the GPU only.
Definition: ResourceGpuCopyDescriptor.h:12
nkGraphics::TEX_RENDER_FLAG
TEX_RENDER_FLAG
The render flag possible for a texture.
Definition: Texture.h:22
nkGraphics::TEX_TYPE::TEX_3D
@ TEX_3D
A 3D texture.
nkGraphics::Texture::getHeight
virtual int getHeight() const =0
nkGraphics::Texture::create
static nkMemory::UniquePtr< Texture > create(System *system=nullptr)
nkImages::Image
Holds all information required for an image, with ownership over the data.
Definition: Image.h:14
nkGraphics::BUFFER_BIND_FLAG
BUFFER_BIND_FLAG
Available binding flags for buffers.
Definition: BufferBindFlag.h:12
nkGraphics::Texture::gpuCopyFrom
virtual void gpuCopyFrom(Texture &other, const ResourceGpuCopyDescriptor &descriptor)=0
nkGraphics::Texture::setFromImageForward
void setFromImageForward(nkImages::Image &&image)
nkGraphics::Texture::convertToImage
nkImages::Image convertToImage(int mip, int sliceOrArrayIndex)
nkGraphics::ShaderResource
Base class for shader resources. Those are resources that can be fed to a Shader.
Definition: ShaderResource.h:12